package com.itheima.method;

public class MethodDemo1 {
    public static void main(String[] args) {
        System.out.println(getVerifyCode(4));
    }
    //获取一个指定位数的验证码返回。
    public static String getVerifyCode(int length){
        String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length; i++) {
            int index = (int)(Math.random()*str.length());
            char c = str.charAt(index);
            sb.append(c);
        }
        return sb.toString();
    }

}
